; English forum: http://www.purebasic.fr/english/viewtopic.php?t==13467&postdays=0&postorder=asc&start=45
; Author: fsw (updated for PB 4.00 by Andre)
; Date: 28. February 2005
; OS: Windows
; Demo: No

; Small Scintilla Editor
; Need the the Scintilla.dll !!!



; USE IT AT YOUR OWN RISK!!! 
; 
; REMEMBER: THIS IS OLD STUFF FROM 2003... 
; DON"T KNOW WHAT I DID BACK THEN... 
; BUT IT SEEMS TO WORK SOMEHOW - STILL... 
; USE IT AT YOUR OWN RISK!!! 
; 
; by fsw 
; 
; NOT COMPLETELY FINISHED THOUGH.... 
; USE IT AT YOUR OWN RISK!!! 
; 
; test of using the Schintilla library for an editor 
; all Scintilla commands can be used by Sendmessage_(bla,bla... 
; or directly with pointers to the Scintilla commands... 

; -------------------------------------------------------------------------------------------------------------------- 
; this is the header file for the scintilla control 
; by Franco 
; NOT COMPLETELY FINISHED THOUGH.... 
; JUST A PROOF OF CONCEPT!!!!!! 
; 
; 
; 
; USE IT AT YOUR OWN RISK!!! 
; 
; 
; 
;// Scintilla source code edit control 
;/** @file Scintilla.h 
; ** Interface To the edit control. 
; **/ 
;// Copyright 1998-2003 by Neil Hodgson <neilh@scintilla.org> 
;// The License.txt file describes the conditions under which this software may be distributed. 
; 
;// Most of this file is automatically generated from the Scintilla.iface interface definition 
;// file which contains any comments about the definitions. HFacer.py does the generation. 

;#if PLAT_WIN 
;// Return false on failure: 
;bool Scintilla_RegisterClasses(void *hInstance); 
;bool Scintilla_ReleaseResources(); 
;#endif 
;int Scintilla_LinkLexers(); 

;// Here should be placed typedefs For uptr_t, an unsigned integer type large enough To 
;// hold a pointer And sptr_t, a signed integer large enough To hold a pointer. 
;// May need To be changed For 64 bit platforms. 
;#if _MSC_VER >= 1300 
;#include <BaseTsd.h> 
;#endif 
;#ifdef MAXULONG_PTR 
;typedef ULONG_PTR uptr_t; 
;typedef LONG_PTR sptr_t; 
;#else 
;typedef unsigned long uptr_t; 
;typedef long sptr_t; 
;#endif 

;typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, sptr_t lParam); 

;//++Autogenerated -- start of section automatically generated from Scintilla.iface 
#INVALID_POSITION = -1 
#SCI_START = 2000 
#SCI_OPTIONAL_START = 3000 
#SCI_LEXER_START = 4000 
#SCI_ADDTEXT = 2001 
#SCI_ADDSTYLEDTEXT = 2002 
#SCI_INSERTTEXT = 2003 
#SCI_CLEARALL = 2004 
#SCI_CLEARDOCUMENTSTYLE = 2005 
#SCI_GETLENGTH = 2006 
#SCI_GETCHARAT = 2007 
#SCI_GETCURRENTPOS = 2008 
#SCI_GETANCHOR = 2009 
#SCI_GETSTYLEAT = 2010 
#SCI_REDO = 2011 
#SCI_SETUNDOCOLLECTION = 2012 
#SCI_SELECTALL = 2013 
#SCI_SETSAVEPOINT = 2014 
#SCI_GETSTYLEDTEXT = 2015 
#SCI_CANREDO = 2016 
#SCI_MARKERLINEFROMHANDLE = 2017 
#SCI_MARKERDELETEHANDLE = 2018 
#SCI_GETUNDOCOLLECTION = 2019 
#SCWS_INVISIBLE = 0 
#SCWS_VISIBLEALWAYS = 1 
#SCWS_VISIBLEAFTERINDENT = 2 
#SCI_GETVIEWWS = 2020 
#SCI_SETVIEWWS = 2021 
#SCI_POSITIONFROMPOINT = 2022 
#SCI_POSITIONFROMPOINTCLOSE = 2023 
#SCI_GOTOLINE = 2024 
#SCI_GOTOPOS = 2025 
#SCI_SETANCHOR = 2026 
#SCI_GETCURLINE = 2027 
#SCI_GETENDSTYLED = 2028 
#SC_EOL_CRLF = 0 
#SC_EOL_CR = 1 
#SC_EOL_LF = 2 
#SCI_CONVERTEOLS = 2029 
#SCI_GETEOLMODE = 2030 
#SCI_SETEOLMODE = 2031 
#SCI_STARTSTYLING = 2032 
#SCI_SETSTYLING = 2033 
#SCI_GETBUFFEREDDRAW = 2034 
#SCI_SETBUFFEREDDRAW = 2035 
#SCI_SETTABWIDTH = 2036 
#SCI_GETTABWIDTH = 2121 
#SC_CP_UTF8 = 65001 
#SC_CP_DBCS = 1 
#SCI_SETCODEPAGE = 2037 
#SCI_SETUSEPALETTE = 2039 
#MARKER_MAX = 31 
#SC_MARK_CIRCLE = 0 
#SC_MARK_ROUNDRECT = 1 
#SC_MARK_ARROW = 2 
#SC_MARK_SMALLRECT = 3 
#SC_MARK_SHORTARROW = 4 
#SC_MARK_EMPTY = 5 
#SC_MARK_ARROWDOWN = 6 
#SC_MARK_MINUS = 7 
#SC_MARK_PLUS = 8 
#SC_MARK_VLINE = 9 
#SC_MARK_LCORNER = 10 
#SC_MARK_TCORNER = 11 
#SC_MARK_BOXPLUS = 12 
#SC_MARK_BOXPLUSCONNECTED = 13 
#SC_MARK_BOXMINUS = 14 
#SC_MARK_BOXMINUSCONNECTED = 15 
#SC_MARK_LCORNERCURVE = 16 
#SC_MARK_TCORNERCURVE = 17 
#SC_MARK_CIRCLEPLUS = 18 
#SC_MARK_CIRCLEPLUSCONNECTED = 19 
#SC_MARK_CIRCLEMINUS = 20 
#SC_MARK_CIRCLEMINUSCONNECTED = 21 
#SC_MARK_BACKGROUND = 22 
#SC_MARK_DOTDOTDOT = 23 
#SC_MARK_ARROWS = 24 
#SC_MARK_PIXMAP = 25 
#SC_MARK_CHARACTER = 10000 
#SC_MARKNUM_FOLDEREND = 25 
#SC_MARKNUM_FOLDEROPENMID = 26 
#SC_MARKNUM_FOLDERMIDTAIL = 27 
#SC_MARKNUM_FOLDERTAIL = 28 
#SC_MARKNUM_FOLDERSUB = 29 
#SC_MARKNUM_FOLDER = 30 
#SC_MARKNUM_FOLDEROPEN = 31 
;#SC_MASK_FOLDERS 0xFE000000 
#SCI_MARKERDEFINE = 2040 
#SCI_MARKERSETFORE = 2041 
#SCI_MARKERSETBACK = 2042 
#SCI_MARKERADD = 2043 
#SCI_MARKERDELETE = 2044 
#SCI_MARKERDELETEALL = 2045 
#SCI_MARKERGET = 2046 
#SCI_MARKERNEXT = 2047 
#SCI_MARKERPREVIOUS = 2048 
#SCI_MARKERDEFINEPIXMAP = 2049 
#SC_MARGIN_SYMBOL = 0 
#SC_MARGIN_NUMBER = 1 
#SCI_SETMARGINTYPEN = 2240 
#SCI_GETMARGINTYPEN = 2241 
#SCI_SETMARGINWIDTHN = 2242 
#SCI_GETMARGINWIDTHN = 2243 
#SCI_SETMARGINMASKN = 2244 
#SCI_GETMARGINMASKN = 2245 
#SCI_SETMARGINSENSITIVEN = 2246 
#SCI_GETMARGINSENSITIVEN = 2247 
#STYLE_DEFAULT = 32 
#STYLE_LINENUMBER = 33 
#STYLE_BRACELIGHT = 34 
#STYLE_BRACEBAD = 35 
#STYLE_CONTROLCHAR = 36 
#STYLE_INDENTGUIDE = 37 
#STYLE_LASTPREDEFINED = 39 
#STYLE_MAX = 127 
#SC_CHARSET_ANSI = 0 
#SC_CHARSET_DEFAULT = 1 
#SC_CHARSET_BALTIC = 186 
#SC_CHARSET_CHINESEBIG5 = 136 
#SC_CHARSET_EASTEUROPE = 238 
#SC_CHARSET_GB2312 = 134 
#SC_CHARSET_GREEK = 161 
#SC_CHARSET_HANGUL = 129 
#SC_CHARSET_MAC = 77 
#SC_CHARSET_OEM = 255 
#SC_CHARSET_RUSSIAN = 204 
#SC_CHARSET_SHIFTJIS = 128 
#SC_CHARSET_SYMBOL = 2 
#SC_CHARSET_TURKISH = 162 
#SC_CHARSET_JOHAB = 130 
#SC_CHARSET_HEBREW = 177 
#SC_CHARSET_ARABIC = 178 
#SC_CHARSET_VIETNAMESE = 163 
#SC_CHARSET_THAI = 222 
#SCI_STYLECLEARALL = 2050 
#SCI_STYLESETFORE = 2051 
#SCI_STYLESETBACK = 2052 
#SCI_STYLESETBOLD = 2053 
#SCI_STYLESETITALIC = 2054 
#SCI_STYLESETSIZE = 2055 
#SCI_STYLESETFONT = 2056 
#SCI_STYLESETEOLFILLED = 2057 
#SCI_STYLERESETDEFAULT = 2058 
#SCI_STYLESETUNDERLINE = 2059 
#SC_CASE_MIXED = 0 
#SC_CASE_UPPER = 1 
#SC_CASE_LOWER = 2 
#SCI_STYLESETCASE = 2060 
#SCI_STYLESETCHARACTERSET = 2066 
#SCI_STYLESETHOTSPOT = 2409 
#SCI_SETSELFORE = 2067 
#SCI_SETSELBACK = 2068 
#SCI_SETCARETFORE = 2069 
#SCI_ASSIGNCMDKEY = 2070 
#SCI_CLEARCMDKEY = 2071 
#SCI_CLEARALLCMDKEYS = 2072 
#SCI_SETSTYLINGEX = 2073 
#SCI_STYLESETVISIBLE = 2074 
#SCI_GETCARETPERIOD = 2075 
#SCI_SETCARETPERIOD = 2076 
#SCI_SETWORDCHARS = 2077 
#SCI_BEGINUNDOACTION = 2078 
#SCI_ENDUNDOACTION = 2079 
#INDIC_MAX = 7 
#INDIC_PLAIN = 0 
#INDIC_SQUIGGLE = 1 
#INDIC_TT = 2 
#INDIC_DIAGONAL = 3 
#INDIC_STRIKE = 4 
;#INDIC0_MASK 0x20 
;#INDIC1_MASK 0x40 
;#INDIC2_MASK 0x80 
;#INDICS_MASK 0xE0 
#SCI_INDICSETSTYLE = 2080 
#SCI_INDICGETSTYLE = 2081 
#SCI_INDICSETFORE = 2082 
#SCI_INDICGETFORE = 2083 
#SCI_SETWHITESPACEFORE = 2084 
#SCI_SETWHITESPACEBACK = 2085 
#SCI_SETSTYLEBITS = 2090 
#SCI_GETSTYLEBITS = 2091 
#SCI_SETLINESTATE = 2092 
#SCI_GETLINESTATE = 2093 
#SCI_GETMAXLINESTATE = 2094 
#SCI_GETCARETLINEVISIBLE = 2095 
#SCI_SETCARETLINEVISIBLE = 2096 
#SCI_GETCARETLINEBACK = 2097 
#SCI_SETCARETLINEBACK = 2098 
#SCI_STYLESETCHANGEABLE = 2099 
#SCI_AUTOCSHOW = 2100 
#SCI_AUTOCCANCEL = 2101 
#SCI_AUTOCACTIVE = 2102 
#SCI_AUTOCPOSSTART = 2103 
#SCI_AUTOCCOMPLETE = 2104 
#SCI_AUTOCSTOPS = 2105 
#SCI_AUTOCSETSEPARATOR = 2106 
#SCI_AUTOCGETSEPARATOR = 2107 
#SCI_AUTOCSELECT = 2108 
#SCI_AUTOCSETCANCELATSTART = 2110 
#SCI_AUTOCGETCANCELATSTART = 2111 
#SCI_AUTOCSETFILLUPS = 2112 
#SCI_AUTOCSETCHOOSESINGLE = 2113 
#SCI_AUTOCGETCHOOSESINGLE = 2114 
#SCI_AUTOCSETIGNORECASE = 2115 
#SCI_AUTOCGETIGNORECASE = 2116 
#SCI_USERLISTSHOW = 2117 
#SCI_AUTOCSETAUTOHIDE = 2118 
#SCI_AUTOCGETAUTOHIDE = 2119 
#SCI_AUTOCSETDROPRESTOFWORD = 2270 
#SCI_AUTOCGETDROPRESTOFWORD = 2271 
#SCI_REGISTERIMAGE = 2405 
#SCI_CLEARREGISTEREDIMAGES = 2408 
#SCI_AUTOCGETTYPESEPARATOR = 2285 
#SCI_AUTOCSETTYPESEPARATOR = 2286 
#SCI_SETINDENT = 2122 
#SCI_GETINDENT = 2123 
#SCI_SETUSETABS = 2124 
#SCI_GETUSETABS = 2125 
#SCI_SETLINEINDENTATION = 2126 
#SCI_GETLINEINDENTATION = 2127 
#SCI_GETLINEINDENTPOSITION = 2128 
#SCI_GETCOLUMN = 2129 
#SCI_SETHSCROLLBAR = 2130 
#SCI_GETHSCROLLBAR = 2131 
#SCI_SETINDENTATIONGUIDES = 2132 
#SCI_GETINDENTATIONGUIDES = 2133 
#SCI_SETHIGHLIGHTGUIDE = 2134 
#SCI_GETHIGHLIGHTGUIDE = 2135 
#SCI_GETLINEENDPOSITION = 2136 
#SCI_GETCODEPAGE = 2137 
#SCI_GETCARETFORE = 2138 
#SCI_GETUSEPALETTE = 2139 
#SCI_GETREADONLY = 2140 
#SCI_SETCURRENTPOS = 2141 
#SCI_SETSELECTIONSTART = 2142 
#SCI_GETSELECTIONSTART = 2143 
#SCI_SETSELECTIONEND = 2144 
#SCI_GETSELECTIONEND = 2145 
#SCI_SETPRINTMAGNIFICATION = 2146 
#SCI_GETPRINTMAGNIFICATION = 2147 
#SC_PRINT_NORMAL = 0 
#SC_PRINT_INVERTLIGHT = 1 
#SC_PRINT_BLACKONWHITE = 2 
#SC_PRINT_COLOURONWHITE = 3 
#SC_PRINT_COLOURONWHITEDEFAULTBG = 4 
#SCI_SETPRINTCOLOURMODE = 2148 
#SCI_GETPRINTCOLOURMODE = 2149 
#SCFIND_WHOLEWORD = 2 
#SCFIND_MATCHCASE = 4 
;#SCFIND_WORDSTART 0x00100000 
;#SCFIND_REGEXP 0x00200000 
;#SCFIND_POSIX 0x00400000 
#SCI_FINDTEXT = 2150 
#SCI_FORMATRANGE = 2151 
#SCI_GETFIRSTVISIBLELINE = 2152 
#SCI_GETLINE = 2153 
#SCI_GETLINECOUNT = 2154 
#SCI_SETMARGINLEFT = 2155 
#SCI_GETMARGINLEFT = 2156 
#SCI_SETMARGINRIGHT = 2157 
#SCI_GETMARGINRIGHT = 2158 
#SCI_GETMODIFY = 2159 
#SCI_SETSEL = 2160 
#SCI_GETSELTEXT = 2161 
#SCI_GETTEXTRANGE = 2162 
#SCI_HIDESELECTION = 2163 
#SCI_POINTXFROMPOSITION = 2164 
#SCI_POINTYFROMPOSITION = 2165 
#SCI_LINEFROMPOSITION = 2166 
#SCI_POSITIONFROMLINE = 2167 
#SCI_LINESCROLL = 2168 
#SCI_SCROLLCARET = 2169 
#SCI_REPLACESEL = 2170 
#SCI_SETREADONLY = 2171 
#SCI_NULL = 2172 
#SCI_CANPASTE = 2173 
#SCI_CANUNDO = 2174 
#SCI_EMPTYUNDOBUFFER = 2175 
#SCI_UNDO = 2176 
#SCI_CUT = 2177 
#SCI_COPY = 2178 
#SCI_PASTE = 2179 
#SCI_CLEAR = 2180 
#SCI_SETTEXT = 2181 
#SCI_GETTEXT = 2182 
#SCI_GETTEXTLENGTH = 2183 
#SCI_GETDIRECTFUNCTION = 2184 
#SCI_GETDIRECTPOINTER = 2185 
#SCI_SETOVERTYPE = 2186 
#SCI_GETOVERTYPE = 2187 
#SCI_SETCARETWIDTH = 2188 
#SCI_GETCARETWIDTH = 2189 
#SCI_SETTARGETSTART = 2190 
#SCI_GETTARGETSTART = 2191 
#SCI_SETTARGETEND = 2192 
#SCI_GETTARGETEND = 2193 
#SCI_REPLACETARGET = 2194 
#SCI_REPLACETARGETRE = 2195 
#SCI_SEARCHINTARGET = 2197 
#SCI_SETSEARCHFLAGS = 2198 
#SCI_GETSEARCHFLAGS = 2199 
#SCI_CALLTIPSHOW = 2200 
#SCI_CALLTIPCANCEL = 2201 
#SCI_CALLTIPACTIVE = 2202 
#SCI_CALLTIPPOSSTART = 2203 
#SCI_CALLTIPSETHLT = 2204 
#SCI_CALLTIPSETBACK = 2205 
#SCI_CALLTIPSETFORE = 2206 
#SCI_CALLTIPSETFOREHLT = 2207 
#SCI_VISIBLEFROMDOCLINE = 2220 
#SCI_DOCLINEFROMVISIBLE = 2221 
;#SC_FOLDLEVELBASE 0x400 
;#SC_FOLDLEVELWHITEFLAG 0x1000 
;#SC_FOLDLEVELHEADERFLAG 0x2000 
;#SC_FOLDLEVELBOXHEADERFLAG 0x4000 
;#SC_FOLDLEVELBOXFOOTERFLAG 0x8000 
;#SC_FOLDLEVELCONTRACTED 0x10000 
;#SC_FOLDLEVELUNINDENT 0x20000 
;#SC_FOLDLEVELNUMBERMASK 0x0FFF 
#SCI_SETFOLDLEVEL = 2222 
#SCI_GETFOLDLEVEL = 2223 
#SCI_GETLASTCHILD = 2224 
#SCI_GETFOLDPARENT = 2225 
#SCI_SHOWLINES = 2226 
#SCI_HIDELINES = 2227 
#SCI_GETLINEVISIBLE = 2228 
#SCI_SETFOLDEXPANDED = 2229 
#SCI_GETFOLDEXPANDED = 2230 
#SCI_TOGGLEFOLD = 2231 
#SCI_ENSUREVISIBLE = 2232 
;#SC_FOLDFLAG_LINEBEFORE_EXPANDED 0x0002 
;#SC_FOLDFLAG_LINEBEFORE_CONTRACTED 0x0004 
;#SC_FOLDFLAG_LINEAFTER_EXPANDED 0x0008 
;#SC_FOLDFLAG_LINEAFTER_CONTRACTED 0x0010 
;#SC_FOLDFLAG_LEVELNUMBERS 0x0040 
;#SC_FOLDFLAG_BOX 0x0001 
#SCI_SETFOLDFLAGS = 2233 
#SCI_ENSUREVISIBLEENFORCEPOLICY = 2234 
#SCI_SETTABINDENTS = 2260 
#SCI_GETTABINDENTS = 2261 
#SCI_SETBACKSPACEUNINDENTS = 2262 
#SCI_GETBACKSPACEUNINDENTS = 2263 
#SC_TIME_FOREVER = 10000000 
#SCI_SETMOUSEDWELLTIME = 2264 
#SCI_GETMOUSEDWELLTIME = 2265 
#SCI_WORDSTARTPOSITION = 2266 
#SCI_WORDENDPOSITION = 2267 
#SC_WRAP_NONE = 0 
#SC_WRAP_WORD = 1 
#SCI_SETWRAPMODE = 2268 
#SCI_GETWRAPMODE = 2269 
#SC_CACHE_NONE = 0 
#SC_CACHE_CARET = 1 
#SC_CACHE_PAGE = 2 
#SC_CACHE_DOCUMENT = 3 
#SCI_SETLAYOUTCACHE = 2272 
#SCI_GETLAYOUTCACHE = 2273 
#SCI_SETSCROLLWIDTH = 2274 
#SCI_GETSCROLLWIDTH = 2275 
#SCI_TEXTWIDTH = 2276 
#SCI_SETENDATLASTLINE = 2277 
#SCI_GETENDATLASTLINE = 2278 
#SCI_TEXTHEIGHT = 2279 
#SCI_SETVSCROLLBAR = 2280 
#SCI_GETVSCROLLBAR = 2281 
#SCI_APPENDTEXT = 2282 
#SCI_GETTWOPHASEDRAW = 2283 
#SCI_SETTWOPHASEDRAW = 2284 
#SCI_TARGETFROMSELECTION = 2287 
#SCI_LINESJOIN = 2288 
#SCI_LINESSPLIT = 2289 
#SCI_SETFOLDMARGINCOLOUR = 2290 
#SCI_SETFOLDMARGINHICOLOUR = 2291 
#SCI_LINEDOWN = 2300 
#SCI_LINEDOWNEXTEND = 2301 
#SCI_LINEUP = 2302 
#SCI_LINEUPEXTEND = 2303 
#SCI_CHARLEFT = 2304 
#SCI_CHARLEFTEXTEND = 2305 
#SCI_CHARRIGHT = 2306 
#SCI_CHARRIGHTEXTEND = 2307 
#SCI_WORDLEFT = 2308 
#SCI_WORDLEFTEXTEND = 2309 
#SCI_WORDRIGHT = 2310 
#SCI_WORDRIGHTEXTEND = 2311 
#SCI_HOME = 2312 
#SCI_HOMEEXTEND = 2313 
#SCI_LINEEND = 2314 
#SCI_LINEENDEXTEND = 2315 
#SCI_DOCUMENTSTART = 2316 
#SCI_DOCUMENTSTARTEXTEND = 2317 
#SCI_DOCUMENTEND = 2318 
#SCI_DOCUMENTENDEXTEND = 2319 
#SCI_PAGEUP = 2320 
#SCI_PAGEUPEXTEND = 2321 
#SCI_PAGEDOWN = 2322 
#SCI_PAGEDOWNEXTEND = 2323 
#SCI_EDITTOGGLEOVERTYPE = 2324 
#SCI_CANCEL = 2325 
#SCI_DELETEBACK = 2326 
#SCI_TAB = 2327 
#SCI_BACKTAB = 2328 
#SCI_NEWLINE = 2329 
#SCI_FORMFEED = 2330 
#SCI_VCHOME = 2331 
#SCI_VCHOMEEXTEND = 2332 
#SCI_ZOOMIN = 2333 
#SCI_ZOOMOUT = 2334 
#SCI_DELWORDLEFT = 2335 
#SCI_DELWORDRIGHT = 2336 
#SCI_LINECUT = 2337 
#SCI_LINEDELETE = 2338 
#SCI_LINETRANSPOSE = 2339 
#SCI_LINEDUPLICATE = 2404 
#SCI_LOWERCASE = 2340 
#SCI_UPPERCASE = 2341 
#SCI_LINESCROLLDOWN = 2342 
#SCI_LINESCROLLUP = 2343 
#SCI_DELETEBACKNOTLINE = 2344 
#SCI_HOMEDISPLAY = 2345 
#SCI_HOMEDISPLAYEXTEND = 2346 
#SCI_LINEENDDISPLAY = 2347 
#SCI_LINEENDDISPLAYEXTEND = 2348 
#SCI_HOMEWRAP = 2349 
#SCI_HOMEWRAPEXTEND = 2450 
#SCI_LINEENDWRAP = 2451 
#SCI_LINEENDWRAPEXTEND = 2452 
#SCI_VCHOMEWRAP = 2453 
#SCI_VCHOMEWRAPEXTEND = 2454 
#SCI_MOVECARETINSIDEVIEW = 2401 
#SCI_LINELENGTH = 2350 
#SCI_BRACEHIGHLIGHT = 2351 
#SCI_BRACEBADLIGHT = 2352 
#SCI_BRACEMATCH = 2353 
#SCI_GETVIEWEOL = 2355 
#SCI_SETVIEWEOL = 2356 
#SCI_GETDOCPOINTER = 2357 
#SCI_SETDOCPOINTER = 2358 
#SCI_SETMODEVENTMASK = 2359 
#EDGE_NONE = 0 
#EDGE_LINE = 1 
#EDGE_BACKGROUND = 2 
#SCI_GETEDGECOLUMN = 2360 
#SCI_SETEDGECOLUMN = 2361 
#SCI_GETEDGEMODE = 2362 
#SCI_SETEDGEMODE = 2363 
#SCI_GETEDGECOLOUR = 2364 
#SCI_SETEDGECOLOUR = 2365 
#SCI_SEARCHANCHOR = 2366 
#SCI_SEARCHNEXT = 2367 
#SCI_SEARCHPREV = 2368 
#SCI_LINESONSCREEN = 2370 
#SCI_USEPOPUP = 2371 
#SCI_SELECTIONISRECTANGLE = 2372 
#SCI_SETZOOM = 2373 
#SCI_GETZOOM = 2374 
#SCI_CREATEDOCUMENT = 2375 
#SCI_ADDREFDOCUMENT = 2376 
#SCI_RELEASEDOCUMENT = 2377 
#SCI_GETMODEVENTMASK = 2378 
#SCI_SETFOCUS = 2380 
#SCI_GETFOCUS = 2381 
#SCI_SETSTATUS = 2382 
#SCI_GETSTATUS = 2383 
#SCI_SETMOUSEDOWNCAPTURES = 2384 
#SCI_GETMOUSEDOWNCAPTURES = 2385 
#SC_CURSORNORMAL = -1 
#SC_CURSORWAIT = 4 
#SCI_SETCURSOR = 2386 
#SCI_GETCURSOR = 2387 
#SCI_SETCONTROLCHARSYMBOL = 2388 
#SCI_GETCONTROLCHARSYMBOL = 2389 
#SCI_WORDPARTLEFT = 2390 
#SCI_WORDPARTLEFTEXTEND = 2391 
#SCI_WORDPARTRIGHT = 2392 
#SCI_WORDPARTRIGHTEXTEND = 2393 
;#VISIBLE_SLOP 0x01 
;#VISIBLE_STRICT 0x04 
#SCI_SETVISIBLEPOLICY = 2394 
#SCI_DELLINELEFT = 2395 
#SCI_DELLINERIGHT = 2396 
#SCI_SETXOFFSET = 2397 
#SCI_GETXOFFSET = 2398 
#SCI_CHOOSECARETX = 2399 
#SCI_GRABFOCUS = 2400 
;#CARET_SLOP 0x01 
;#CARET_STRICT 0x04 
;#CARET_JUMPS 0x10 
;#CARET_EVEN 0x08 
#SCI_SETXCARETPOLICY = 2402 
#SCI_SETYCARETPOLICY = 2403 
#SCI_SETPRINTWRAPMODE = 2406 
#SCI_GETPRINTWRAPMODE = 2407 
#SCI_SETHOTSPOTACTIVEFORE = 2410 
#SCI_SETHOTSPOTACTIVEBACK = 2411 
#SCI_SETHOTSPOTACTIVEUNDERLINE = 2412 
#SCI_PARADOWN = 2413 
#SCI_PARADOWNEXTEND = 2414 
#SCI_PARAUP = 2415 
#SCI_PARAUPEXTEND = 2416 
#SCI_STARTRECORD = 3001 
#SCI_STOPRECORD = 3002 
#SCI_SETLEXER = 4001 
#SCI_GETLEXER = 4002 
#SCI_COLOURISE = 4003 
#SCI_SETPROPERTY = 4004 
#SCI_SETKEYWORDS = 4005 
#SCI_SETLEXERLANGUAGE = 4006 
#SCI_LOADLEXERLIBRARY = 4007 
;#SC_MOD_INSERTTEXT 0x1 
;#SC_MOD_DELETETEXT 0x2 
;#SC_MOD_CHANGESTYLE 0x4 
;#SC_MOD_CHANGEFOLD 0x8 
;#SC_PERFORMED_USER 0x10 
;#SC_PERFORMED_UNDO 0x20 
;#SC_PERFORMED_REDO 0x40 
;#SC_LASTSTEPINUNDOREDO 0x100 
;#SC_MOD_CHANGEMARKER 0x200 
;#SC_MOD_BEFOREINSERT 0x400 
;#SC_MOD_BEFOREDELETE 0x800 
;#SC_MODEVENTMASKALL 0xF77 
#SCEN_CHANGE = 768 
#SCEN_SETFOCUS = 512 
#SCEN_KILLFOCUS = 256 
#SCK_DOWN = 300 
#SCK_UP = 301 
#SCK_LEFT = 302 
#SCK_RIGHT = 303 
#SCK_HOME = 304 
#SCK_END = 305 
#SCK_PRIOR = 306 
#SCK_NEXT = 307 
#SCK_DELETE = 308 
#SCK_INSERT = 309 
#SCK_ESCAPE = 7 
#SCK_BACK = 8 
#SCK_TAB = 9 
#SCK_RETURN = 13 
#SCK_ADD = 310 
#SCK_SUBTRACT = 311 
#SCK_DIVIDE = 312 
#SCMOD_SHIFT = 1 
#SCMOD_CTRL = 2 
#SCMOD_ALT = 4 
#SCN_STYLENEEDED = 2000 
#SCN_CHARADDED = 2001 
#SCN_SAVEPOINTREACHED = 2002 
#SCN_SAVEPOINTLEFT = 2003 
#SCN_MODIFYATTEMPTRO = 2004 
#SCN_KEY = 2005 
#SCN_DOUBLECLICK = 2006 
#SCN_UPDATEUI = 2007 
#SCN_MODIFIED = 2008 
#SCN_MACRORECORD = 2009 
#SCN_MARGINCLICK = 2010 
#SCN_NEEDSHOWN = 2011 
#SCN_PAINTED = 2013 
#SCN_USERLISTSELECTION = 2014 
#SCN_URIDROPPED = 2015 
#SCN_DWELLSTART = 2016 
#SCN_DWELLEND = 2017 
#SCN_ZOOM = 2018 
#SCN_HOTSPOTCLICK = 2019 
#SCN_HOTSPOTDOUBLECLICK = 2020 
#SCN_CALLTIPCLICK = 2021 
;//--Autogenerated -- End of section automatically generated from Scintilla.iface 

;// These structures are defined To be exactly the same shape as the Win32 
;// CHARRANGE, TEXTRANGE, FINDTEXTEX, FORMATRANGE, And NMHDR structs. 
;// So older code that treats Scintilla as a RichEdit will work. 

;Structure CharacterRange 
;  cpMin.l 
;  cpMax.l 
;EndStructure 

;Structure TextRange 
;  chrg.CharacterRange 
;  *lpstrText.s 
;EndStructure 

;Structure TextToFind 
;  chrg.CharacterRange 
;  *lpstrText.s 
;  chrgText.CharacterRange 
;EndStructure 

;#ifdef PLATFORM_H 

;// This Structure is used in printing And requires some of the graphics types 
;// from Platform.h.  Not needed by most client code. 

;struct RangeToFormat { 
; SurfaceID hdc; 
; SurfaceID hdcTarget; 
; PRectangle rc; 
; PRectangle rcPage; 
; CharacterRange chrg; 
;}; 

;#endif 

;struct NotifyHeader { 
; // hwndFrom is really an environment specifc window handle Or pointer 
; // but most clients of Scintilla.h do not have this type visible. 
; //WindowID hwndFrom; 
; void *hwndFrom; 
; unsigned int idFrom; 
; unsigned int code; 
;}; 

Structure SCNotification 
  NotifyHeader.NMHDR 
  position.l          ;   // SCN_STYLENEEDED, SCN_MODIFIED, SCN_DWELLSTART, SCN_DWELLEND 
  ch.l                ;   // SCN_CHARADDED, SCN_KEY 
  modifiers.l         ;   // SCN_KEY 
  modificationType.l  ;   // SCN_MODIFIED 
  *text.s             ;   // SCN_MODIFIED 
  length.l            ;   // SCN_MODIFIED 
  linesAdded.l        ;   // SCN_MODIFIED 
  message.l           ;   // SCN_MACRORECORD 
  wParam.l            ;   // SCN_MACRORECORD 
  lParam.l            ;   // SCN_MACRORECORD 
  line.l              ;   // SCN_MODIFIED 
  foldLevelNow.l      ;   // SCN_MODIFIED 
  foldLevelPrev.l     ;   // SCN_MODIFIED 
  margin.l            ;   // SCN_MARGINCLICK 
  listType.l          ;   // SCN_USERLISTSELECTION 
  x.l                 ;   // SCN_DWELLSTART, SCN_DWELLEND 
  y.l                 ;   // SCN_DWELLSTART, SCN_DWELLEND 
EndStructure 

;// Deprecation section listing all API features that are deprecated And will 
;// will be removed completely in a future version. 
;// To enable these features define INCLUDE_DEPRECATED_FEATURES; 

;#ifdef INCLUDE_DEPRECATED_FEATURES; 

#SCI_SETCARETPOLICY = 2369 
;#CARET_CENTER = 0x02 
;#CARET_XEVEN = 0x08 
;#CARET_XJUMPS = 0x10 

#SCN_POSCHANGED = 2012 
#SCN_CHECKBRACE = 2007 

; -------------------------------------------------------------------------------------------------------------------- 

; USE IT AT YOUR OWN RISK!!! 
; 
; REMEMBER: THIS IS OLD STUFF FROM 2003... 
; DON"T KNOW WHAT I DID BACK THEN... 
; BUT IT SEEMS TO WORK SOMEHOW - STILL... 
; USE IT AT YOUR OWN RISK!!! 



Declare SaveAsSourceFile(hwndScintilla) 
; 
; this is the structure for the scintilla callbacks 
;STRUC NMHDR 
;.hwndFrom RESD 1 
;.idfrom RESD 1 
;.code RESD 1 
;ENDSTRUC 
Global lpnmhdr.NMHDR 
; 
; this is the handle of the scintilla control 
Global hwndSciEditGadget 
; 
; this is the footer of a purebasic source code 
Structure PureBasicSourceFile 
  FileName.s 
  ExecutableFormat.s 
  Executable.s 
  UseIcon.s 
  EnableAsm.b 
  EnableNT4.b 
  EnableXP.b 
EndStructure 

Global Make.PureBasicSourceFile 
; 
; when creating a new file... 
Procedure ClearMakeFileInfo() 
  Make\FileName = "New File" 
  Make\ExecutableFormat = "" 
  Make\Executable = "" 
  Make\UseIcon = "" 
  Make\EnableAsm = 0 
  Make\EnableNT4 = 0 
  Make\EnableXP = 0 
EndProcedure 
; 
Procedure RedrawWindow() 
  ;this needs to be in a own procedure to work properly... 
  WindowEvent() : WindowEvent() : WindowEvent() 
  WindowEvent() : WindowEvent() : WindowEvent() 
EndProcedure 

; seems to work... 
Procedure SciEditGadget(hwndParent,x,y,w,h) 
  hmod = OpenLibrary(1, "SciLexer.dll") 
  If (hmod) = 0 
    MessageRequester( "Error loading Scintilla", "The Scintilla DLL could not be loaded.", #MB_OK | #MB_ICONERROR) 
    End
  Else 
    hInstance = GetModuleHandle_(0) 
    hwndScintilla = CreateWindowEx_(0, "Scintilla"," ", #WS_CHILD|#WS_VISIBLE|#WS_TABSTOP,x,y,w,h,hwndParent,0,hInstance,0) 
  EndIf 
  ShowWindow_(hwndScintilla, #SW_SHOWNORMAL) 
  ProcedureReturn hwndScintilla 
EndProcedure 


Procedure SCI_ShowVScrollBar(hwndScintilla) 
  SendMessage_(hwndScintilla, #SCI_SETVSCROLLBAR, 1, 0) 
EndProcedure 

Procedure SCI_Undo(hwndScintilla) 
  SendMessage_(hwndScintilla, #SCI_UNDO, 0, 0) 
EndProcedure 

Procedure SCI_Redo(hwndScintilla) 
  SendMessage_(hwndScintilla, #SCI_REDO, 0, 0) 
EndProcedure 

Procedure SCI_SetSavePoint(hwndScintilla) 
  SendMessage_(hwndScintilla, #SCI_SETSAVEPOINT, 0, 0) 
EndProcedure 

Procedure SCI_Cut(hwndScintilla) 
  SendMessage_(hwndScintilla, #SCI_CUT, 0, 0) 
EndProcedure 

Procedure SCI_Copy(hwndScintilla) 
  SendMessage_(hwndScintilla, #SCI_COPY, 0, 0) 
EndProcedure 

Procedure SCI_Paste(hwndScintilla) 
  SendMessage_(hwndScintilla, #SCI_PASTE, 0, 0) 
EndProcedure 

Procedure SCI_SelectAll(hwndScintilla) 
  SendMessage_(hwndScintilla, #SCI_SELECTALL, 0, 0) 
EndProcedure 

Procedure SCI_GotoLine(hwndScintilla,Line) 
  SendMessage_(hwndScintilla, #SCI_GOTOLINE, Line, 0) 
  SetFocus_(hwndScintilla) 
;  SendMessage_(hwndScintilla, #SCI_SETCURRENTPOS, Line, 0) 
EndProcedure 

; seems to work... 
Procedure SCI_ClearAll(hwndScintilla) 
  SendMessage_(hwndScintilla, #SCI_CLEARALL, 0, 0) 
EndProcedure 

; seems to work... 
Procedure SCI_NewLine(hwndScintilla) 
  SendMessage_(hwndScintilla, #SCI_NEWLINE, 0, 0) 
EndProcedure 

; seems to work... 
Procedure SCI_FormFeed(hwndScintilla) 
  SendMessage_(hwndScintilla, #SCI_FORMFEED, 0, 0) 
EndProcedure 


; seems to work... 
Procedure SCI_AddText(hwndScintilla, String$) 
  Length = Len(String$) 
  SendMessage_(hwndScintilla, #SCI_ADDTEXT, Length, String$) 
EndProcedure 

Procedure SCI_SetText(hwndScintilla, *StringBuffer) 
  SendMessage_(hwndScintilla, #SCI_SETTEXT, 0, *StringBuffer) 
EndProcedure 

Procedure SCI_GetLine(hwndScintilla, Line, *StringBuffer) 
  ProcedureReturn SendMessage_(hwndScintilla, #SCI_GETLINE, Line, *StringBuffer) 
EndProcedure 

; Returns the number of lines in the document. There is always at least one. 
; seems to work... 
Procedure SCI_GetLineCount(hwndScintilla) 
  ProcedureReturn SendMessage_(hwndScintilla, #SCI_GETLINECOUNT, 0, 0) - 1 
EndProcedure 

Procedure SCI_LineLength(hwndScintilla, Line) 
  ProcedureReturn SendMessage_(hwndScintilla, #SCI_LINELENGTH, Line, 0) -1 
EndProcedure 

;Is the document different from when it was last saved? 
Procedure SCI_GetModify(hwndScintilla) 
  ProcedureReturn SendMessage_(hwndScintilla, #SCI_GETMODIFY, 0, 0) 
EndProcedure 

;# Retrieve the x value of the point in the window where a position is displayed. 
Procedure SCI_PointXFromPosition(hwndScintilla,x) 
  ProcedureReturn SendMessage_(hwndScintilla, #SCI_POINTXFROMPOSITION, 0, x) 
EndProcedure 

;# Retrieve the y value of the point in the window where a position is displayed. 
Procedure SCI_PointYFromPosition(hwndScintilla,y) 
  ProcedureReturn SendMessage_(hwndScintilla, #SCI_POINTYFROMPOSITION, 0, y) 
EndProcedure 



Procedure WindowCallback(WindowID, Message, wParam, lParam) 
  ReturnValue = #PB_ProcessPureBasicEvents 
  Shared hwndSciEditGadget 
  
  Select Message 
    Case #WM_MOVE 

    Case #WM_SIZE 
      ;UpdateStatusBar(0) 
      ResizeGadget(0, 8, 28, WindowWidth(WindowID)-16,WindowHeight(WindowID)-56) 

      ;ResizeScintillaGadget() 
      SetWindowPos_(hwndSciEditGadget,0,10,30,WindowWidth(WindowID)-20,WindowHeight(WindowID)-60,0) 

      ;ReturnValue = 1 

    Case #WM_NOTIFY 
;        *lpnmhdr.NMHDR = lParam ;works 
        *lpnmhdr.NMHDR = EventlParam() ;works 
        Select *lpnmhdr\hwndFrom 
        
          Case hwndSciEditGadget 
          
            Select *lpnmhdr\code 
            
              Case #SCN_CHARADDED 
           ;     Debug SCI_GetModify(hwndSciEditGadget) 
        ;        Debug SCI_PointXFromPosition(hwndSciEditGadget,0) 
        ;        Debug SCI_PointYFromPosition(hwndSciEditGadget,0) 
           ;     Debug SCI_GetLineCount(hwndSciEditGadget) 

;                MessageRequester("Scintilla code: "+Str(*lpnmhdr\code), "A new char came up...",0) 
                
            EndSelect 
            
        EndSelect 
        
    EndSelect 
    
    ProcedureReturn  ReturnValue 

EndProcedure 


Procedure NewSourceFile(hwndScintilla) 
  SCI_ClearAll(hwndScintilla) 
  ClearMakeFileInfo() 
  SCI_SetSavePoint(hwndScintilla) 
EndProcedure 
        
Procedure OpenSourceFile(hwndScintilla) ; AddText 
  Make\FileName = OpenFileRequester("Open File","","PureBasic file |*.PB| All Files |*.*",0) 

  If OpenFile(1, Make\FileName) 
    SCI_ClearAll(hwndScintilla) 

    FileSeek(1, Lof(1) - 1) 
    Repeat 
      EndByte = ReadByte (1) 
      Position = Loc(1) 
      FileSeek(1, Loc(1) - 2) 
    Until EndByte = 0 Or Position = 1 

    If Position = 1 
      EndPosition = Lof(1) 
     ; MessageRequester("Title","Special 'End of text' character not found...",0) 
    Else 
      EndPosition = Loc(1) 
      ; MessageRequester("Title","End of text"+ Str(EndPosition),0) 
      FileSeek(1, EndPosition) 
      
      Repeat 
        Text$ = ReadString(1) 
        TextExecutableFormat$ = Left(Text$,19) 
        If TextExecutableFormat$ = "; ExecutableFormat=" 
          Make\ExecutableFormat = RemoveString(Text$, "; ExecutableFormat=", 1) 
        EndIf 
        TextExecutable$ = Left(Text$,13) 
        If TextExecutable$ = "; Executable=" 
          Make\Executable = RemoveString(Text$, "; Executable=", 1) 
        EndIf 
        TextUseIcon$ = Left(Text$,10) 
        If TextUseIcon$ = "; UseIcon=" 
          Make\UseIcon = RemoveString(Text$, "; UseIcon=", 1) 
        EndIf 
        If Text$ = "; EnableAsm" 
          Make\EnableAsm = 1 
        EndIf 
        If Text$ = "; EnableNT4" 
          Make\EnableNT4 = 1 
        EndIf 
        If Text$ = "; EnableXP" 
          Make\EnableXP = 1 
        EndIf 
      Until Loc(1) >= Lof(1) 
    EndIf 

    FileSeek(1, 0) 

    Repeat 
      Text$ = ReadString(1) 
      SCI_AddText(hwndScintilla, Text$ + Chr(10)) 
;      SCI_NewLine(hwndSciEditGadget) 
;      SCI_FormFeed(hwndSciEditGadget) 
    Until Loc(1) >= EndPosition 

    CloseFile(1) 
    WindowEvent() : WindowEvent() : WindowEvent() 
    SCI_SetSavePoint(hwndScintilla) 
  Else 
    If Len(Make\FileName) > 0 
      MessageRequester("Error","Can't open file...",0) 
    EndIf 
  EndIf 
EndProcedure 

Procedure SaveSourceFile(hwndScintilla) 
;  Shared ExecutableFormat$ 
  ;Make\FileName = "MyTestSave.pb" 
  If Make\FileName = "New File" 
    Make\FileName = SaveFileRequester("Save As",Make\FileName,"PureBasic file |*.PB| All Files |*.*",0) + ".pb" 
  EndIf 
  
 If Make\FileName = ".pb" 
    Make\FileName = "New File" 
 Else 
;  If ExamineDirectory(1, "", Make\FileName) 
;    Result = MessageRequester(Make\FileName,"Overwrite this file?",#PB_MessageRequester_YesNo) 
;    If Result = 6    
      DeleteFile(Make\FileName + ".bak") 
      If RenameFile(Make\FileName, Make\FileName + ".bak") 
        DeleteFile(Make\FileName) 
      EndIf 
;    EndIf 
;  EndIf 
  
  If OpenFile(1,Make\FileName) 
    Lines = SCI_GetLineCount(hwndScintilla) 

    For CurrentLine = 0 To Lines 
      Size = SCI_LineLength(hwndScintilla, CurrentLine) 
      If Size >= 0 
        String$ = Space(Size + 1) 
        SCI_GetLine(hwndScintilla, CurrentLine, @String$) 
        WriteString(1, Left(String$, Size + 1)) 
      EndIf 
    Next 
    
    WriteByte(1, 0) 
    WriteStringN(1, "") 
    If Len(Make\ExecutableFormat) > 0 
      WriteStringN(1, "; ExecutableFormat=" + Make\ExecutableFormat) 
    EndIf 
    If Len(Make\Executable) > 0 
      WriteStringN(1, "; Executable=" + Make\Executable) 
    EndIf 
    If Len(Make\UseIcon) > 0 
      WriteStringN(1, "; UseIcon=" + Make\UseIcon) 
    EndIf 
    If Make\EnableAsm 
      WriteStringN(1, "; " + "EnableAsm") 
    EndIf 
    If Make\EnableNT4 
      WriteStringN(1, "; " + "EnableNT4") 
    EndIf 
    If Make\EnableXP 
      WriteStringN(1, "; " + "EnableXP") 
    EndIf 
    WriteStringN(1, "; EOF") 
    CloseFile(1) 
    SCI_SetSavePoint(hwndScintilla) 
  EndIf 
 EndIf 
  
EndProcedure 

Procedure SaveAsSourceFile(hwndScintilla) 
  Make\FileName = SaveFileRequester("Save As",Make\FileName,"PureBasic file |*.PB| All Files |*.*",0) + ".pb" 
  SaveSourceFile(hwndScintilla) 
EndProcedure 

Procedure CloseSourceFile(hwndScintilla) 
;  Ckeck 
  If SCI_GetModify(hwndSciEditGadget) 
    Result = MessageRequester(Make\FileName,"File changed, save this file?",#PB_MessageRequester_YesNoCancel) 
   ; Debug Result 
    
    If Result = 2 ; cancel 
    Else 
      If Result = 6  ; yes 
        SaveSourceFile(hwndScintilla) 
      EndIf 
      SCI_ClearAll(hwndScintilla) 
      SCI_SetSavePoint(hwndScintilla) 
      ClearMakeFileInfo() 
    EndIf 
  Else 
    SCI_ClearAll(hwndScintilla) 
    SCI_SetSavePoint(hwndScintilla) 
    ClearMakeFileInfo() 
  EndIf 
EndProcedure 


; main 
If OpenWindow(0, 150, 150, 320,240, "SciEdit for PureBasic", #PB_Window_SystemMenu |#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget) 

  CreateMenu(1,WindowID(0)) 
  MenuTitle("File") 
  MenuItem(0, "&New" + Chr(9) + "Ctrl+N") 
  MenuItem(1, "&Open" + Chr(9) + "Ctrl+O") 
  MenuItem(2, "&Save" + Chr(9) + "Ctrl+S") 
  MenuItem(3, "&Save As...") 
  MenuItem(4, "&Close" + Chr(9) + "Ctrl+W") 
  MenuBar() 
  MenuItem(5, "&Quit") 
  MenuTitle("Edit") 
  MenuItem(10, "&Undo" + Chr(9) + "Ctrl+Z") 
  MenuItem(11, "&Redo" + Chr(9) + "Ctrl+Y") 
  MenuBar() 
  MenuItem(12, "&Cut" + Chr(9) + "Ctrl+X") 
  MenuItem(13, "&Copy" + Chr(9) + "Ctrl+C") 
  MenuItem(14, "&Paste" + Chr(9) + "Ctrl+V") 
  MenuBar() 
  MenuItem(15, "&Select All" + Chr(9) + "Ctrl+A") 
  MenuBar() 
  MenuItem(16, "&Goto..." + Chr(9) + "Ctrl+G") 


  CreateToolBar(1,WindowID(0)) 
  ToolBarStandardButton(0, #PB_ToolBarIcon_New) 
  ToolBarToolTip(1, 0, "New File") 
  ToolBarStandardButton(1, #PB_ToolBarIcon_Open) 
  ToolBarToolTip(1, 1, "Open File") 
  ToolBarStandardButton(2, #PB_ToolBarIcon_Save) 
  ToolBarToolTip(1, 2, "Save File") 
  ToolBarSeparator() 
  ToolBarStandardButton(4, #PB_ToolBarIcon_Delete) 
  ToolBarToolTip(1, 4, "Close File") 
  ToolBarSeparator() 
  ToolBarStandardButton(12, #PB_ToolBarIcon_Cut) 
  ToolBarToolTip(1, 12, "Cut") 
  ToolBarStandardButton(13, #PB_ToolBarIcon_Copy) 
  ToolBarToolTip(1, 13, "Copy") 
  ToolBarStandardButton(14, #PB_ToolBarIcon_Paste) 
  ToolBarToolTip(1, 14, "Paste") 
  
  ;create Edit Gadget 
  CreateGadgetList(WindowID(0)) 
  Frame3DGadget(0, 8, 28, WindowWidth(0)-16,WindowHeight(0)-56, "", #PB_Frame3D_Double) 
  hwndSciEditGadget=SciEditGadget(WindowID(0),10,30,WindowWidth(0)-20,WindowHeight(0)-60) 

;  SayHelloID = CreateThread(@SayHello(), hwndSciEditGadget) 
;  SayHello(hwndSciEditGadget) 
  ;KillThread(SayHelloID) 
  
  ; start... 
  NewSourceFile(hwndSciEditGadget) 
  ; done... 
;    Lines = SCI_GetLineCount(hwndSciEditGadget) 
;    Debug Lines 
  SetWindowCallback(@WindowCallback()) 
  
  SCI_ShowVScrollBar(hwndSciEditGadget) 

  Repeat 
    EventID.l = WaitWindowEvent() 
    Select EventID 
  
      Case #PB_Event_Menu 

        Select EventMenu() 
          Case 0 
            CloseSourceFile(hwndSciEditGadget) 
            NewSourceFile(hwndSciEditGadget) 
          Case 1 
            CloseSourceFile(hwndSciEditGadget) 
            OpenSourceFile(hwndSciEditGadget) 
;            Debug SCI_GetLineCount(hwndSciEditGadget) 
;            Debug SCI_GetModify(hwndSciEditGadget) 
;            Debug SCI_LineLength(hwndSciEditGadget, 3) 
          Case 2 
            SaveSourceFile(hwndSciEditGadget) 
            
          Case 3 
            SaveAsSourceFile(hwndSciEditGadget) 

          Case 4 
            CloseSourceFile(hwndSciEditGadget) 

          Case 5 
            EventID = #PB_Event_CloseWindow 
            
          Case 10 
            SCI_Undo(hwndSciEditGadget) 

          Case 11 
            SCI_Redo(hwndSciEditGadget) 

          Case 12 
            SCI_Cut(hwndSciEditGadget) 

          Case 13 
            SCI_Copy(hwndSciEditGadget) 

          Case 14 
            SCI_Paste(hwndSciEditGadget) 

          Case 15 
            SCI_SelectAll(hwndSciEditGadget) 

          Case 16 
            SCI_GotoLine(hwndSciEditGadget,Val(InputRequester("Goto","","")) - 1) 

        EndSelect 

    EndSelect 
    
  Until EventID = #PB_Event_CloseWindow 
  
  CloseSourceFile(hwndSciEditGadget) 
  
EndIf 
  DestroyWindow_(hwndSciEditGadget) 
End 

; IDE Options = PureBasic v4.02 (Windows - x86)
; Folding = -----